#include <iostream>
#include <memory>
#include <string>
class Fruit
{
public:
    virtual void Name() = 0;
};

class Apple : public Fruit
{
public:
    void Name() override
    {
        printf("我是一个苹果\n");
    }
};

class Banana : public Fruit
{
public:
    void Name() override
    {
        printf("我是一个香蕉\n");
    }
};

class FruitFactory
{
public:
    static std::shared_ptr<Fruit> MakeAFruit(std::string name)
    {
        if (name == "苹果")
        {
            return std::make_shared<Apple>();
        }
        else
        {
            return std::make_shared<Banana>();
        }
    }
};

int main()
{
    std::shared_ptr<Fruit> ptr = FruitFactory::MakeAFruit("香蕉");
    ptr->Name();
}